package cn.aj.org.dto;

import cn.aj.org.domain.Employee;
import cn.aj.org.domain.Shop;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ShopSettlementDto {
    @NotBlank(message = "店铺名不能为空!")
    private String name;
    @NotBlank(message = "电话名不能为空!")
    private String tel;

    /**
     * 店铺状态：0待审核，1待激活，3驳回，3激活
     */
    private Integer state = 0;
    @NotBlank(message = "地址名不能为空!")
    private String address;
    private String logo;
    private Long adminId;

    // 封装员工的admin,必须是这个字段,否者接不到
    @NotNull(message = "店铺管理员不能为空!")
    private Employee admin;

    /**
     * @Title: getShop
     * @Description: TODO
     * @Author: Mr.GT
     * @Version: 1.0
     * @Date:  2022/11/22 0022 0:24
     * @Parameters: []
     * @Return cn.aj.org.domain.Shop
     * 店铺需要的字段
     */
    public Shop getShop() {
        return  Shop.builder()
                .name(this.getName())
                .tel(this.getTel())
                .address(this.getAddress())
                .logo(this.getLogo())
                .registerTime(new Date())
                .state(0)
                .build();

    }

    /**
     * @Title: getEmp
     * @Description: TODO
     * @Author: Mr.GT
     * @Version: 1.0
     * @Date:  2022/11/22 0022 0:24
     * @Parameters: []
     * @Return cn.aj.org.domain.Employee
     * admin需要的字段
     */
    public Employee getEmp(){
        Employee employee = new Employee();
        BeanUtils.copyProperties(admin,employee);
        employee.setAge(19);
        employee.setState(11);
        return employee;
    }
}
